const common = require('./webpack.common');
const { merge } = require('webpack-merge');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = merge(common,{
    mode: 'production', 
    optimization:{
        usedExports:true,
        minimize: true,
        splitChunks:{
            chunks:'all'
        }        
    },
    module:{
        rules:[
            {
                test: /\.(js|vue)$/,
                exclude: /(node_modules|bower_components)/,
                use: {
                  loader: 'eslint-loader',
                  options: {
                    fix: true,
                    cache: false,
                    failOnError: false,
                    rules: {
                        indent: ["error", 4]
                    }
                }                    
                },
                enforce:"pre",
            }
        ]       
    },    
    plugins:[
        new CleanWebpackPlugin(),
        new MiniCssExtractPlugin({
            filename:'[name]-[hash].bundle.css'
        }),
    ]
})
